package com.erpanderp.wam.tm.view;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import com.erpanderp.wam.tm.model.entity.RecruitmentRequest;
import com.erpanderp.wam.tm.model.service.RRFDAO;
import com.erpanderp.wam.usm.model.entity.user.WAMUser;
import com.erpanderp.wam.util.CommonLookup;

@ManagedBean
@ViewScoped
public class HrRRFListBean implements Serializable {


	private static final long serialVersionUID = 1L;
	private HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
	private WAMUser wamUser = (WAMUser) session.getAttribute(CommonLookup.SESSION_ATTRIBUTE_WAMUSER);	

	private RRFDAO rrfDAO = new RRFDAO();
	
	private List<RecruitmentRequest> recruitmentRequestList = new ArrayList<RecruitmentRequest>();
	
	public HrRRFListBean() {

		if (wamUser != null) {
			setRecruitmentRequestList(rrfDAO.getAllRRFs());
			//renderUploadButton=true;
		}else{
			System.out.println("WAM USER NULL=======");
		}
	}
	
	//Approver reommendations FORM 
	  public String generateOfferLeterAction() {
		 try{
				  Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

				  String rrfCode = params.get("rrfCode");
				  String activity=params.get("activity");
				  
				  System.out.println("activity::::::::::"+activity);
				  
				  FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("rrfCode", rrfCode);		  
				  FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("activity", activity);
	 
				  FacesContext.getCurrentInstance().getExternalContext().redirect("/wam/tm/scheduleinterviews.html?rrfCode="+rrfCode+"&activity="+activity);
				
			  }catch (Exception e) {
				  e.printStackTrace();
			 }
			 return "scheduleinterviews";
		} 
	//GETTERS AND SETTERS
	public WAMUser getWamUser() {
		return wamUser;
	}

	public void setWamUser(WAMUser wamUser) {
		this.wamUser = wamUser;
	}

	public List<RecruitmentRequest> getRecruitmentRequestList() {
		return recruitmentRequestList;
	}

	public void setRecruitmentRequestList(List<RecruitmentRequest> recruitmentRequestList) {
		this.recruitmentRequestList = recruitmentRequestList;
	}

}
